<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../vue文件/vue.js"></script>
</head>
<body>
    <div id="app">
        <ul>
            <!--    index是下标 -->
            <!-- 用到v-for 就要用到key key的值必须是唯一的 -->
            <li v-for='(count,index) in 10' 
                :key="index"
                @click='change(index)' 
                :class="{on:index==num&&index%2==0,off:index==num&&index%2!=0}">
                   {{count}}
            </li>
        </ul>
    </div>
</body>
<script>
    let vm = new Vue({
        el:'#app',
        data:{
            num:null
        },
        methods:{
            change(index){
                this.num = index;
            }
        }
    })
</script>
<style>
    .on{
        background-color: #cccccc;
    }
    .off{
        background-color: red;
    }
</style>
</html>